package com.msa.msaportal.controller;

import java.io.IOException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.msa.msaportal.common.json.JsonTurn;
import com.msa.msaportal.common.web.JavaTimeUtils;
import com.msa.msaportal.common.page.Pagination;
import com.msa.msaportal.common.web.ConstantUntil;
import com.msa.msaportal.common.web.MsaJsonUntil;
import com.msa.msaportal.common.web.ResponseUtils;
import com.msa.msaportal.entity.PortalCssEntity;
import com.msa.msaportal.entity.PortalExample;
import com.msa.msaportal.entity.PortalFunction;
import com.msa.msaportal.entity.PortalPage;
import com.msa.msaportal.entity.PortalRole;
import com.msa.msaportal.entity.PortletEntity;
import com.msa.msaportal.entity.PortletViewRes;
import com.msa.msaportal.entity.Template;
import com.msa.msaportal.service.IPortalCssEntityService;
import com.msa.msaportal.service.IPortalExampleService;
import com.msa.msaportal.service.IPortalPageService;
import com.msa.msaportal.service.IPortalRoleService;
import com.msa.msaportal.service.ITemplateService;

@Controller
@RequestMapping("/portalAdmin")
public class PortalExampleController {

	@Resource(name="portalManager")
	private IPortalExampleService portalManager;
	@Resource(name="portalcssManager")
	private IPortalCssEntityService portalcssManager;
	@Resource(name="templateManager")
	private ITemplateService templateManager;
	@Resource(name="pageManager")
	private IPortalPageService pageManager;
	@Resource(name="roleManager")
	private IPortalRoleService roleManager;
	/**
	 * portal管理主页面
	 * @param model
	 * @return
	 * @throws RemoteException
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping("/portalMain.do")
	public String portalMain(ModelMap model,HttpSession session) throws RemoteException{
		
		String userId = (String) session.getAttribute("loginUserId");
		//从ldap获取用户信息
		String udjson = MsaJsonUntil.getJsonByUserId(userId);
		
		JSONObject jobj=JSONObject.fromObject(udjson);
		String userCn = jobj.getJSONObject("datas").getJSONObject("table").getJSONObject("row").getString("userName");
		String role = (String) session.getAttribute("productRoleid");
		List<PortalFunction> functionList = new ArrayList<PortalFunction>();
		List<PortalFunction> functionchildrenList = new ArrayList<PortalFunction>();
		functionList.clear();
		functionchildrenList.clear();
		Integer roleId = 0;
		String [] str = new String[role.split(",").length];
		role = role.substring(0, role.length()-1);
		str = role.split(",");
		for(int j=0;j<str.length;j++){
			System.out.println("roleshuzu:"+str[j]+","+functionList.size());
			roleId = Integer.valueOf(str[j]);
			PortalRole portalRole = roleManager.findById(roleId);
			Set<PortalFunction> portalfunction =portalRole.getPortalFunction();
			for(Iterator it=portalfunction.iterator();it.hasNext();){
				PortalFunction  pf = (PortalFunction) it.next();
				if(pf.getFunctionsort().equals("bar") && pf.getPerent_id()==0){
					if(functionList.size()>0){
						String functionid = ",";
						for(int i=0;i<functionList.size();i++){
							functionid += functionList.get(i).getFunctionId()+",";
						}
						if(functionid.indexOf(","+pf.getFunctionId().toString()+",")==-1){								
							functionList.add(pf);
						}
					}else{
						functionList.add(pf);
					}
					
					
				}else if(pf.getFunctionsort().equals("bar") && pf.getPerent_id()!=0){
					if(functionchildrenList.size()>0){
						String functionchild = ",";
						for(int i=0;i<functionchildrenList.size();i++){
							functionchild += functionchildrenList.get(i).getFunctionId()+",";
						}
						if(functionchild.indexOf(","+pf.getFunctionId().toString()+",")==-1){
							functionchildrenList.add(pf);
						}
					}else{
						functionchildrenList.add(pf);
					}
					
				}
				
			}
		}
		
		model.addAttribute("userName", userCn);
		model.addAttribute("barlist", functionList);
		model.addAttribute("barchildrenlist", functionchildrenList);
		
		return "/portalMain";
	}
	/**
	 * 新建门户实例页
	 * @param model
	 * @return
	 * @throws RemoteException
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping("/addPortal.do")
	public String addPortal(ModelMap model,HttpSession session) throws RemoteException{
		String userId = (String) session.getAttribute("loginUserId");
		//从ldap获取用户信息
		String udjson = MsaJsonUntil.getJsonByUserId(userId);		
		JSONObject jobj=JSONObject.fromObject(udjson);
		String userCn = jobj.getJSONObject("datas").getJSONObject("table").getJSONObject("row").getString("userName");
		//String userNumber = jobj.getJSONObject("datas").getJSONObject("table").getJSONObject("row").getString("idNumber");
		JSONArray jsonorgarry = jobj.getJSONObject("datas").getJSONObject("table").getJSONObject("row").getJSONArray("table");
		String orgName= "";
		for(int j=0;j<jsonorgarry.size();j++){
			if("org".equals(jsonorgarry.getJSONObject(j).getString("tableName"))){
				orgName= jsonorgarry.getJSONObject(j).getJSONArray("row").getJSONObject(0).getString("orgName");
			}
		}
		
		String orgCode = jobj.getJSONObject("datas").getJSONObject("table").getJSONObject("row").getString("organizations");
		
		//查询可用模板和样式
		List<Template> tlist = portalManager.getTemplatelistByorgId(orgCode);
		List<PortalCssEntity> clist = portalcssManager.getcssEntityListByorgId(orgCode);
		//查询可用页面模块资源
		List<PortletViewRes> portletViewreslist = portalManager.getportletlistByorgCode(orgCode);
		//功能权限控制
		//Integer roleid = Integer.valueOf(session.getAttribute("productRoleid").toString());
		String rolestr = (String) session.getAttribute("productRoleid");
		String [] str = new String[rolestr.split(",").length];
		rolestr = rolestr.substring(0, rolestr.length()-1);
		str = rolestr.split(",");
		String add_example = "";
		for(int j=0;j<str.length;j++){
			PortalRole portalRole = roleManager.findById(Integer.valueOf(str[j]));
			Set<PortalFunction> portalfunction =portalRole.getPortalFunction();			
			for(Iterator it=portalfunction.iterator();it.hasNext();){
				PortalFunction  pf = (PortalFunction) it.next();
				if(pf.getFunctionCode().equals("example_new")){
					add_example = pf.getFunctionCode();
				}
				
			}
		}
		
		model.addAttribute("userName", userCn);
		model.addAttribute("userId", userId);
		model.addAttribute("orgName", orgName);
		model.addAttribute("orgCode", orgCode);
		model.addAttribute("templatelist", tlist);
		model.addAttribute("portalcsslist", clist);
		model.addAttribute("add_example", add_example);
		model.addAttribute("portletViewreslist", portletViewreslist);
		return "/geteExample";
		
	}
	
	@RequestMapping("/savePortal.do")
	public void savePortal(PortalExample portalExample,PortalPage portalPage,
			ModelMap model,HttpServletRequest request,HttpServletResponse response){
		
		portalExample.setCreatetime(JavaTimeUtils.getCurrentTime());
		portalExample.setExpose(false);
		portalExample.setStatus(false);
		portalExample.setUse_on(false);
		portalExample = portalManager.savePortal(portalExample);
		
		portalPage.setCreateuserId(portalExample.getCreateuserid());
		portalPage.setCreateuserName(portalExample.getCreateusername());
		portalPage.setIsnavview(true);
		portalPage.setIsview(true);
		portalPage.setPageCode(ConstantUntil.HOMEPAGECODE);
		portalPage.setPageName(ConstantUntil.HOMEPAGENAME);
		portalPage.setPortalExample(portalExample);
		portalPage.setCreatetime(JavaTimeUtils.getCurrentTime());
		portalPage = pageManager.addPage(portalPage);
		ResponseUtils.renderText(response, portalPage.getPageId().toString());
	}
	@RequestMapping("/refreshPortal.do")
	public void refreshPortal(Integer pageid,Integer layoutcode,Integer templateid,Integer cssid,
			HttpServletRequest request,HttpServletResponse response){
		PortalPage portalPage = pageManager.findById(pageid);
		PortalExample portalExample = portalPage.getPortalExample();
		portalPage.setPagelayout(layoutcode);
		portalPage.setUpdatetime(JavaTimeUtils.getCurrentTime());
		//获取模板、样式
		PortalCssEntity portalcss = portalcssManager.findById(cssid);
		Template template = templateManager.getObjByid(templateid);

		portalExample.setPortalcss(portalcss);
		portalExample.setTemplate(template);
		portalExample.setUpdatetime(JavaTimeUtils.getCurrentTime());
		//传输更新数据
		pageManager.updatePage(portalPage);
		portalManager.updatePortal(portalExample);
		ResponseUtils.renderText(response, portalPage.getPageId().toString());
	}
		
	/**
   	 * 查询portalExample
   	 * @param portalExample
   	 * @param pageNo
   	 * @param userNum
   	 * @param request
   	 * @param response
   	 */		
	@SuppressWarnings("rawtypes")
	@RequestMapping("/findPortal.do")
	public void findPortal(HttpServletRequest request,HttpServletResponse response,HttpSession session,PortalExample  portalExample,Integer pageNo,String cmsrole) throws IOException{
		
		String userId = (String) session.getAttribute("loginUserId");
		//从ldap获取用户信息
		String udjson = MsaJsonUntil.getJsonByUserId(userId);
		JSONObject jobj=JSONObject.fromObject(udjson);
		if(portalExample.getOrgid()==null||portalExample.getOrgid().equals("")){
			
			String orgCode = jobj.getJSONObject("datas").getJSONObject("table").getJSONObject("row").getString("organizations");
			portalExample.setOrgid(orgCode);
		}
		Pagination list1 = portalManager.findPortal(portalExample,Pagination.cpn(pageNo),Pagination.DEF_COUNT);
		JSONObject obj = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		JSONObject json = new JSONObject();
		obj.put("maxPageNum", list1.getTotalPage());
		obj.put("pageNum", list1.getPageNo());
		obj.put("totalCount", list1.getTotalCount());
		
		//权限控制
		String rolestr = (String) session.getAttribute("productRoleid");
		String [] str = new String[rolestr.split(",").length];
		rolestr = rolestr.substring(0, rolestr.length()-1);
		str = rolestr.split(",");
		String examplelook = "";//实例查看
		String exampleattr = "";//属性编辑
		String examplecont = "";//内容编辑
		String example_del = "";//实例删除
		if(cmsrole==null||"".equals(cmsrole)){
			for(int j=0;j<str.length;j++){
				PortalRole portalRole = roleManager.findById(Integer.valueOf(str[j]));
				Set<PortalFunction> portalfunction =portalRole.getPortalFunction();
				for(Iterator it=portalfunction.iterator();it.hasNext();){
					PortalFunction  pf = (PortalFunction) it.next();
					if(pf.getFunctionCode().equals("example_see")){
						examplelook = pf.getFunctionCode();
					}
					if(pf.getFunctionCode().equals("example_attredit")){
						exampleattr = pf.getFunctionCode();
					}
					if(pf.getFunctionCode().equals("example_conedit")){
						examplecont = pf.getFunctionCode();
					}
					if(pf.getFunctionCode().equals("example_remove")){
						example_del = pf.getFunctionCode();
					}
					
				}
			}
			
		}else{
			if(cmsrole.indexOf(ConstantUntil.ENTITYDETAIL)!=-1){
				examplelook = ConstantUntil.EXAMPLE_SEE;
			}
			if(cmsrole.indexOf(ConstantUntil.ENTITYEDITATTR)!=-1){
				exampleattr = ConstantUntil.EXAMPLE_ATTREDIT;
			}
			if(cmsrole.indexOf(ConstantUntil.ENTITYEDITCON)!=-1){
				examplecont = ConstantUntil.EXAMPLE_CONEDIT;
			}
			if(cmsrole.indexOf(ConstantUntil.ENTITYREMOVE)!=-1){
				example_del = ConstantUntil.EXAMPLE_REMOVE;
			}
		}
				
	    for(int i=0;i<list1.getList().size();i++){
	    	
	    	 PortalExample pe = (PortalExample) list1.getList().get(i);
	    	 
	    	
	    	String userOn;
	    	if(pe.isUse_on()){
	    		userOn="已发布";
	    	}else{
	    		userOn="未发布";
	    	}
	    	 
				json.put("portal_id", pe.getPortal_id());
				json.put("portal_code", pe.getPortal_code());
				json.put("portal_name", pe.getPortal_name());
				json.put("orgname", pe.getOrgname());
				json.put("createuserid", pe.getCreateuserid());
				json.put("createusername", pe.getCreateusername());
				json.put("createtime", pe.getCreatetime());
				json.put("updateuserid", pe.getUpdateuserid());
				json.put("updateusername", pe.getUpdateusername());
				json.put("updatetime", pe.getUpdatetime());
				json.put("portal_opinion", pe.getPortal_opinion());
				json.put("use_on", userOn);
				json.put("examplelook", examplelook);
				json.put("exampleattr", exampleattr);
				json.put("examplecont", examplecont);
				json.put("example_del", example_del);
				jsonArray.add(json);
	     }
	     	obj.put("list", jsonArray);
	     	response.getWriter().write( obj.toString());				
	}

	   
	/**
   	 * 删除portalExample
   	 * @param portal_id
   	 * @param request
   	 * @param response
   	 */		
	 		   		   
   @RequestMapping("/deletePortal.do")		  
	public void deleteByPortalId(HttpServletRequest request,HttpServletResponse response){
		try {			
			String portal_id=request.getParameter("portal_id");
			PortalExample portalExample  = portalManager.findByPortalid(portal_id);
			if(portalExample.isUse_on()){
				JsonTurn.returnJson("no", response);
			}else{
			portalManager.deleteByPortalId(portal_id);
			JsonTurn.returnJson("ok", response);
			}
		} catch (IOException e) {
			try {
				JsonTurn.returnJson("error", response);
			} catch (IOException e1) {
				e1.printStackTrace();
			}

		}
		
		
	}
   	/**
   	 * 保存portlet
   	 * @param pageid
   	 * @param portletEntity
   	 * @param request
   	 * @param response
   	 */
    @RequestMapping("/savePortlet.do")
	public void savePortlet(Integer pageid,PortletEntity portletEntity,Integer viewresid,Integer portletorder,
			HttpServletRequest request,HttpServletResponse response){
		PortalPage portalPage = pageManager.findById(pageid);
		PortletViewRes portletviewRes = pageManager.findPortletRes(viewresid);
		portletEntity.setPortalPage(portalPage);
		portletEntity.setPortletorder(portletorder);
		portletEntity.setPortletName(portletviewRes.getView_name());
		portletEntity.setPortletview(portletviewRes.getView_url());
		pageManager.savePortlet(portletEntity);
		
	}
    
    /**
     * 编辑内容里的添加功能
     * @param portal_id
     * @param pagerow
     * @param portletEntity
     * @param viewresid
     * @param request
     * @param response
     */
    @RequestMapping("/updPortlet.do")
  	public void updPortlet(Integer portal_id,Integer pagerow,PortletEntity portletEntity,Integer viewresid,
  			HttpServletRequest request,HttpServletResponse response){
  		PortalPage portalPage = pageManager.findPortalId(portal_id);
  		PortletViewRes portletviewRes = pageManager.findPortletRes(viewresid);
  		portletEntity.setPortalPage(portalPage);
  		portletEntity.setPagerow(pagerow);
  		portletEntity.setPortletorder(1);
  		portletEntity.setPortletName(portletviewRes.getView_name());
		portletEntity.setPortletview(portletviewRes.getView_url());
  		
  		pageManager.savePortlet(portletEntity);
  		
  	}
    
    /**
     * 编辑内容里的编辑Portlet
     * @param viewresid
     * @param portletview
     * @param portletdesc
     * @param request
     * @param response
     */
    @RequestMapping("/udPortlet.do")
  	public void udPortlet(Integer viewresid,String portletview,String portletdesc,	HttpServletRequest request,HttpServletResponse response){     
    	String portletId=request.getParameter("portletId");
    	Integer id = Integer.valueOf(portletId);
    	
    	PortletEntity portlet = pageManager.findPortletById(id); 
    	PortletViewRes portletviewRes = pageManager.findPortletRes(viewresid);
    	   portlet.setPortletName(portletviewRes.getView_name());
           portlet.setPortletdesc(portletdesc);
           portlet.setPortletId(id);       
           portlet.setPortletview(portletviewRes.getView_url());
          
           pageManager.updatePortlet(portlet); 		
          
  	}
    
    
    
    
    /**
     * 获取portlet
     * @param pageid
     * @param request
     * @param response
     */
	@RequestMapping("/getPortlet.do")
    public void getPortlet(Integer pageid,HttpServletRequest request,HttpServletResponse response){
		System.out.println("getportlet"+pageid);
		List<PortletEntity> portletlist = pageManager.getPortletlistBypageId(pageid);
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		for(int i=0;i<portletlist.size();i++){
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("portletName", portletlist.get(i).getPortletName());
			map.put("portletId", portletlist.get(i).getPortletId());
			map.put("pagerow", portletlist.get(i).getPagerow());
			map.put("portletorder", portletlist.get(i).getPortletorder());
			list.add(map);
		}
		JSONArray json=JSONArray.fromObject(list);
		ResponseUtils.renderJson(response, json.toString());
    }
	
	
	 /**
     * 编辑时获取portlet
     * @param pageid
     * @param request
     * @param response
	 * @param portal_id 
     */
	@RequestMapping("/getUpdPortlet.do")
    public void getUpdPortlet(Integer portal_id,HttpServletRequest request,HttpServletResponse response){
		PortalPage portalPage = pageManager.findPortalId(portal_id);
		List<PortletEntity> portletlist = pageManager.getPortletlistBypageId(portalPage.getPageId());
		List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
		for(int i=0;i<portletlist.size();i++){
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("portletName", portletlist.get(i).getPortletName());
			map.put("portletId", portletlist.get(i).getPortletId());
			map.put("pagerow", portletlist.get(i).getPagerow());
			map.put("portletorder", portletlist.get(i).getPortletorder());
			list.add(map);
		}
		JSONArray json=JSONArray.fromObject(list);
		ResponseUtils.renderJson(response, json.toString());
    }
	
	
	/**
	 * 删除portlet
	 * @param portletId
	 * @param request
	 * @param response
	 */
	@RequestMapping("/deletePortlet.do")
	public void deletePortlet(PortletEntity portletEntity,HttpServletRequest request,HttpServletResponse response){
		System.out.println("porteletkey"+portletEntity.getPortletId());
		PortletEntity portlet = pageManager.findPortletById(portletEntity.getPortletId());
		pageManager.deletePortlet(portlet);
		ResponseUtils.renderText(response, "删除成功");
	}
	/**
	 * 保存portlet排序信息
	 * @param portletEntity
	 * @param request
	 * @param response
	 */
	@RequestMapping("/savePortletOrder.do")
	public void savePortletOrder(PortletEntity portletEntity,HttpServletRequest request,HttpServletResponse response){
		PortletEntity entity = pageManager.findPortletById(portletEntity.getPortletId());
		entity.setPortletorder(portletEntity.getPortletorder());
		pageManager.updatePortlet(entity);
		ResponseUtils.renderText(response, "更新成功");
	}
	/**
	 * 修改门户实例状态
	 * @param pageid
	 * @param request
	 * @param response
	 */
	@RequestMapping("/updateStatus.do")
	public void savePortalstatus(Integer pageid,HttpServletRequest request,HttpServletResponse response){
		PortalPage portalPage = pageManager.findById(pageid);
		PortalExample portalExample = portalPage.getPortalExample();
		portalExample.setStatus(true);
		portalManager.updatePortal(portalExample);
	}

	/**
	* 单击查看 门户实例信息
	* @param portal_id
	* @param request
	* @param response
	* @throws IOException
	*/ 
	
	@RequestMapping("/findByPortalid")
	public void findByPortalid(HttpServletRequest request,HttpServletResponse response) throws IOException{
		String portal_id=request.getParameter("portal_id");
	 
		PortalExample portalExample  = portalManager.findByPortalid(portal_id);
		String userOn;
		if(portalExample.isExpose()){
			userOn="是";
		}else{
			userOn="否";
		}
			JSONObject json = new JSONObject();
			json.put("portal_id", portalExample.getPortal_id());
			json.put("portal_code", portalExample.getPortal_code());
			json.put("portal_name", portalExample.getPortal_name());
			json.put("orgname", portalExample.getOrgname());
			json.put("createuserid", portalExample.getCreateuserid());
			json.put("createusername", portalExample.getCreateusername());
			json.put("createtime", portalExample.getCreatetime());
			json.put("updateuserid", portalExample.getUpdateuserid());
			json.put("updateusername", portalExample.getUpdateusername());
			json.put("updatetime", portalExample.getUpdatetime());
			json.put("portal_opinion", portalExample.getPortal_opinion());
			json.put("expose", userOn);
			json.put("template_name", portalExample.getTemplate().getTemplate_name());
			json.put("cssName", portalExample.getPortalcss().getCssName());
			json.put("template_id", portalExample.getTemplate().getTemplate_id());
			json.put("cssid", portalExample.getPortalcss().getCssId());
			for(PortalPage p:portalExample.getPortalPage()){
				if(p.isIsview()&&p.getPageName().equals(ConstantUntil.HOMEPAGENAME)){
					json.put("pagelayout", p.getPagelayout());
				}
				
			}
				
			 response.getWriter().write( json.toString());
		   
	}
	
	/**
	 * 门户实力编辑属性里的修改功能
	 * @param numpublic
	 * @param portalname
	 * @param portal_opinion
	 * @param createusername1
	 * @param createuserid
	 * @param templateid
	 * @param cssid
	 * @param request
	 * @param response
	 * @throws IOException
	 */
	@RequestMapping("/updateByPortalid")
	public  void updateByPortalid(HttpServletRequest request,HttpServletResponse response,String numpublic,String portalname,String portal_opinion, String createusername1,String createuserid,  Integer templateid,Integer cssid) throws IOException{
		String portal_id=request.getParameter("portal_id");
		
		PortalExample portalExample1  = portalManager.findByPortalid(portal_id);
		if("".equals(numpublic)||"1".equals(numpublic)){
			portalExample1.setExpose(true);
		}else{
			portalExample1.setExpose(false);
		}
		portalExample1.setUpdateuserid(createuserid);
		portalExample1.setPortal_name(portalname);
		portalExample1.setUpdateusername(createusername1);
		portalExample1.setPortal_opinion(portal_opinion);
		portalExample1.setUpdatetime(JavaTimeUtils.getCurrentTime());
		//获取模板对象
		Template template =templateManager.getObjByid(templateid);
		portalExample1.setTemplate(template);
		//获取样式对象
		PortalCssEntity portalCssEntity = portalcssManager.findById(cssid);
		portalExample1.setPortalcss(portalCssEntity);
		//获取修改后的对象 执行跟新操作
	    portalManager.updatePortal(portalExample1);
	    JsonTurn.returnJson("ok", response);
			
		   
	}
	
	  /**
     * 查找Portlet
     * @param portletEntity
     * @param request
     * @param response    
     * @throws IOException
     */
    @RequestMapping("/findPortletById.do")
	public void findPortletById(PortletEntity portletEntity,HttpServletRequest request,HttpServletResponse response) throws IOException{
		PortletEntity portlet = pageManager.findPortletById(portletEntity.getPortletId());

		JSONObject json = new JSONObject();
		json.put("portletName",portlet.getPortletName());
		json.put("portletview",portlet.getPortletview());
		json.put("portletdesc",portlet.getPortletdesc());
		json.put("portletId",portlet.getPortletId());
		response.getWriter().write( json.toString());
	}
           
    /**
     * 退出登录
     * @param request
     * @param response
     * @param session
     * @throws IOException
     */
    @RequestMapping("/portallog.do")
    public void portalLogout(HttpServletRequest request,HttpServletResponse response,HttpSession session) throws IOException{	
    	session.removeAttribute("loginUserId");
    	session.removeAttribute("productRoleid"); 	
    	session.removeAttribute("userName"); 	
		session.removeAttribute("roleSet");
		session.removeAttribute("orgCode");
		session.removeAttribute("orgName");
		session.removeAttribute("deptCode");
		session.removeAttribute("deptName");
    	response.sendRedirect(ConstantUntil.LOGOUT_URL);
    }
    
    

}
